/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.logistics.entity.overseaswarehouse;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.base.entity.warehouse.Twarehouse;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 海外仓Entity
 *
 * @author LV
 * @version 2021-03-10
 */
@Table(name = "t_overseas_warehouse", alias = "a", columns = {
        @Column(name = "overseas_warehouse_id", attrName = "overseasWarehouseId", label = "海外仓ID", isPK = true),
        @Column(name = "overseas_warehouse_code", attrName = "overseasWarehouseCode", label = "单据编号"),
        @Column(name = "service_order_id", attrName = "serviceOrderId", label = "服务订单"),
        @Column(name = "customer_id", attrName = "customerId", label = "客户名称"),
        @Column(name = "foreign_businessmen_id", attrName = "foreignBusinessmenId", label = "外商名称", isQuery = false),
        @Column(name = "investor_id", attrName = "investorId", label = "国内资方", isQuery = false),
        @Column(name = "supplier_id", attrName = "supplierId", label = "供货外商", isQuery = false),
        @Column(name = "date", attrName = "date", label = "收车日期"),
        @Column(name = "packing_date", attrName = "packingDate", label = "装箱时间", isQuery = false),
        @Column(name = "finish_date", attrName = "finishDate", label = "出口手续完结时间", isQuery = false),
        @Column(name = "overseas_warehouse", attrName = "overseasWarehouse", label = "海外仓库"),
        @Column(name = "contact", attrName = "contact", label = "仓库联系人", isQuery = false),
        @Column(name = "service_provider", attrName = "serviceProvider", label = "海外仓服务商", isQuery = false),
        @Column(name = "phone", attrName = "phone", label = "联系人联系电话", isQuery = false),
        @Column(name = "sender", attrName = "sender", label = "送车人", isQuery = false),
        @Column(name = "to_port", attrName = "toPort", label = "目的港"),
        @Column(name = "transport_method", attrName = "transportMethod", label = "运输方式"),
        @Column(name = "shipped_flag", attrName = "shippedFlag", label = "是否出运"),
        @Column(name = "remarks", attrName = "remarks", label = "备注", isQuery = false),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
        @Column(name = "tt_payment_order_id", attrName = "ttPaymentOrderId", label = "TT付款单号"),
}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "b",
                on = "b.customer_id = a.customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "c",
                on = "c.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplier", alias = "d",
                on = "d.supplier_id = a.supplier_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "forSupplier", alias = "e",
                on = "e.supplier_id = a.foreign_businessmen_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "inSupplier", alias = "f",
                on = "f.supplier_id = a.investor_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplierProvider", alias = "g",
                on = "g.supplier_id = a.service_provider",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Twarehouse.class, attrName = "warehouse", alias = "h",
                on = "h.warehouse_id = a.overseas_warehouse",
                columns = {
                        @Column(name = "warehouse_id", label = "仓库编号", isPK = true),
                        @Column(name = "warehouse_name", label = "仓库名称"),
                }),
}, orderBy = "a.update_date DESC"
)
public class OverseasWarehouse extends DataEntity<OverseasWarehouse> {

    private static final long serialVersionUID = 1L;
    private String overseasWarehouseId;        // 海外仓ID
    private String overseasWarehouseCode;        // 单据编号
    private String serviceOrderId;        // 服务订单
    private ServiceOrder serviceOrder;
    private String customerId;        // 客户名称
    private Customer customer;
    private String foreignBusinessmenId;        // 外商名称
    private Supplier forSupplier;
    private String investorId;        // 国内资方
    private Supplier inSupplier;
    private String supplierId;        // 供货外商
    private Supplier supplier;
    private Date date;        // 收车日期
    private Date packingDate;        // 装箱时间
    private Date finishDate;        // 出口手续完结时间
    private String overseasWarehouse;        // 海外仓库
    private Twarehouse warehouse;
    private String contact;        // 仓库联系人
    private String serviceProvider;        // 海外仓服务商
    private Supplier supplierProvider;
    private String phone;        // 联系人联系电话
    private String sender;        // 送车人
    private String toPort;        // 目的港
    private String transportMethod;        // 运输方式
    private String shippedFlag;        // 是否出运
    private List<OverseasWarehouseDetail> overseasWarehouseDetailList = ListUtils.newArrayList();        // 子表列表
    private String ttPaymentOrderId; // TT付款单

    public String getTtPaymentOrderId() {
        return ttPaymentOrderId;
    }

    public void setTtPaymentOrderId(String ttPaymentOrderId) {
        this.ttPaymentOrderId = ttPaymentOrderId;
    }

    public OverseasWarehouse() {
        this(null);
    }

    public OverseasWarehouse(String id) {
        super(id);
    }

    public String getOverseasWarehouseId() {
        return overseasWarehouseId;
    }

    public void setOverseasWarehouseId(String overseasWarehouseId) {
        this.overseasWarehouseId = overseasWarehouseId;
    }

    @Length(min = 0, max = 100, message = "单据编号长度不能超过 100 个字符")
    public String getOverseasWarehouseCode() {
        return overseasWarehouseCode;
    }

    public void setOverseasWarehouseCode(String overseasWarehouseCode) {
        this.overseasWarehouseCode = overseasWarehouseCode;
    }

    @Length(min = 0, max = 64, message = "服务订单长度不能超过 64 个字符")
    public String getServiceOrderId() {
        return serviceOrderId;
    }

    public void setServiceOrderId(String serviceOrderId) {
        this.serviceOrderId = serviceOrderId;
    }

    @Length(min = 0, max = 64, message = "客户名称长度不能超过 64 个字符")
    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    @Length(min = 0, max = 64, message = "外商名称长度不能超过 64 个字符")
    public String getForeignBusinessmenId() {
        return foreignBusinessmenId;
    }

    public void setForeignBusinessmenId(String foreignBusinessmenId) {
        this.foreignBusinessmenId = foreignBusinessmenId;
    }

    @Length(min = 0, max = 64, message = "国内资方长度不能超过 64 个字符")
    public String getInvestorId() {
        return investorId;
    }

    public void setInvestorId(String investorId) {
        this.investorId = investorId;
    }

    @Length(min = 0, max = 64, message = "供货外商长度不能超过 64 个字符")
    public String getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(String supplierId) {
        this.supplierId = supplierId;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "收车日期不能为空")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getPackingDate() {
        return packingDate;
    }

    public void setPackingDate(Date packingDate) {
        this.packingDate = packingDate;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getFinishDate() {
        return finishDate;
    }

    public void setFinishDate(Date finishDate) {
        this.finishDate = finishDate;
    }

    @Length(min = 0, max = 64, message = "海外仓库长度不能超过 64 个字符")
    public String getOverseasWarehouse() {
        return overseasWarehouse;
    }

    public void setOverseasWarehouse(String overseasWarehouse) {
        this.overseasWarehouse = overseasWarehouse;
    }

    @NotBlank(message = "仓库联系人不能为空")
    @Length(min = 0, max = 100, message = "仓库联系人长度不能超过 100 个字符")
    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    @Length(min = 0, max = 64, message = "海外仓服务商长度不能超过 64 个字符")
    public String getServiceProvider() {
        return serviceProvider;
    }

    public void setServiceProvider(String serviceProvider) {
        this.serviceProvider = serviceProvider;
    }

    @Length(min = 0, max = 100, message = "联系人联系电话长度不能超过 100 个字符")
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Length(min = 0, max = 100, message = "送车人长度不能超过 100 个字符")
    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    @NotBlank(message = "目的港不能为空")
    @Length(min = 0, max = 2, message = "目的港长度不能超过 2 个字符")
    public String getToPort() {
        return toPort;
    }

    public void setToPort(String toPort) {
        this.toPort = toPort;
    }

    @NotBlank(message = "运输方式不能为空")
    @Length(min = 0, max = 2, message = "运输方式长度不能超过 2 个字符")
    public String getTransportMethod() {
        return transportMethod;
    }

    public void setTransportMethod(String transportMethod) {
        this.transportMethod = transportMethod;
    }

    @Length(min = 0, max = 1, message = "是否出运长度不能超过 1 个字符")
    public String getShippedFlag() {
        return shippedFlag;
    }

    public void setShippedFlag(String shippedFlag) {
        this.shippedFlag = shippedFlag;
    }

    public Date getDate_gte() {
        return sqlMap.getWhere().getValue("date", QueryType.GTE);
    }

    public void setDate_gte(Date date) {
        sqlMap.getWhere().and("date", QueryType.GTE, date);
    }

    public Date getDate_lte() {
        return sqlMap.getWhere().getValue("date", QueryType.LTE);
    }

    public void setDate_lte(Date date) {
        sqlMap.getWhere().and("date", QueryType.LTE, date);
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public List<OverseasWarehouseDetail> getOverseasWarehouseDetailList() {
        return overseasWarehouseDetailList;
    }

    public void setOverseasWarehouseDetailList(List<OverseasWarehouseDetail> overseasWarehouseDetailList) {
        this.overseasWarehouseDetailList = overseasWarehouseDetailList;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Supplier getInSupplier() {
        return inSupplier;
    }

    public void setInSupplier(Supplier inSupplier) {
        this.inSupplier = inSupplier;
    }

    public Supplier getForSupplier() {
        return forSupplier;
    }

    public void setForSupplier(Supplier forSupplier) {
        this.forSupplier = forSupplier;
    }

    public Twarehouse getWarehouse() {
        return warehouse;
    }

    public void setWarehouse(Twarehouse warehouse) {
        this.warehouse = warehouse;
    }

    public Supplier getSupplierProvider() {
        return supplierProvider;
    }

    public void setSupplierProvider(Supplier supplierProvider) {
        this.supplierProvider = supplierProvider;
    }
}